package com.util.security.Display;

/**
 * @ClassName: Keys
 * @Author: commander
 * @Description:
 * @Version: 1.0
 * @Date: 2016/12/18 18:19
 */
public class Keys {
	private String key;
	private char[] ch1, ch2;
	private int[] in;
	private int keyl;

	public Keys(String key) {
		ch1 = key.toCharArray();
		ch2 = key.toCharArray();
		keyl = key.length();
		in = new int[keyl];
		char temp;
		for (int i = 0; i < keyl - 1; i++) {
			int k = i;
			for (int j = i + 1; j < keyl; j++) if (ch1[j] < ch1[k]) k = j;
			if (k > i) {
				temp = ch1[i];
				ch1[i] = ch1[k];
				ch1[k] = temp;
			}
		}
		for (int i = 0; i < keyl; i++) {
			for (int j = 0; j < keyl; j++) {
				if (ch2[i] == ch1[j]) {
					in[i] = j;
				}
			}
		}
	}

	int[] getkey() {
		return in;
	}
}
